home *** CD-ROM | disk | FTP | other *** search
/ Shareware Super Platinum 8 / Shareware Super Platinum 8.iso / mac / PROGTOOL / FLGTST20.ZIP;1 / FLAGTEST.DOC next >
Encoding:
Text File  |  1994-03-27  |  5.9 KB  |  138 lines

  1.  ⁄ƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒø
  2.  ≥  FlagTest version  2.0·  27-03-94     Copyright (c) 1994 by Erik de Neve  ≥
  3.  ¿ƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒŸ
  4.  
  5.   This utility tests the behavior of the Intel 80XXX CPU flags for
  6.   particular instructions or instruction sequences.
  7.   A detailed report is written about how the flags were affected by a
  8.   test routine, which is called with a predefined range of input
  9.   numbers. The output can be redirected to a file.
  10.  
  11.   FlagTest will report the state of all nine conditions on which the
  12.   seventeen ( 8*2 + JCXZ ) possible conditional jumps can be based.
  13.   More than seventeen seem to exist, but this is because of
  14.   the large number of multiple names - e.g. JNB (Jump if Not Below)
  15.   is exactly the same instruction as JAE (Jump if Above and Equal)
  16.   and JNC (Jump if No Carry) - see also the summary below.
  17.  
  18.   Nonexisting flag bit numbers are used to indicate conditions
  19.   based on more than one flag, or on the CX register.
  20.   These are identified in the output by using the names of the
  21.   corresponding conditional jumps that test for them:
  22.  
  23.     32   JCXZ  =     CX=0               CX register is Zero
  24.     33   JGE   =     SF=OF              Greater or Equal  (signed)
  25.     34   JG    =     ZF=0 and SF=OF     Greater           (signed)
  26.     35   JA    =     CF=0 and ZF=0      Above             (unsigned)
  27.  
  28.   Flags or conditions are either  SET, CLEARED, FLIPPED, UNCHANGED,
  29.   or UNDEFINED.
  30.   Undefined here means that certain conditions are inconclusive, for
  31.   example the "ABOVE" condition means CF=0 and ZF=0 , but when at least
  32.   one of these flags displays any action other than a simple SET or
  33.   CLEAR, FlagTest will label the combined result as undefined.
  34.  
  35.   For some instructions, specific flags are officially branded
  36.   "undefined" by Intel - like the state of the parity, sign and zero
  37.   flags after a MUL instruction.
  38.   This means in most cases they DO get set or cleared - as FlagTest will
  39.   show - but you are warned not to rely on the same results for all
  40.   situations, or on all generations of Intel CPU's and their clones.
  41.  
  42.   The turbo pascal source code can be recompiled to test any assembly
  43.   language instruction for any input range; just change the value of
  44.   Startcount and Endcount, and put the instruction(s) to be analyzed as
  45.   inline assembler in the procedure TestRoutine. The globally defined
  46.   word-sized variable COUNT contains the input.
  47.  
  48.   I originally created FlagTest to help design and debug
  49.   complex combinations of conditional jumps, like:
  50.  
  51.      CMP CX,3
  52.      JCXZ  Label0   ; CX = 0
  53.      JA    Label4   ; CX = 4+
  54.      JE    Label3   ; CX = 3
  55.      JPE   Label2   ; CX = 2
  56.      JPO   Label1   ; CX = 1
  57.  
  58.   I know this example has limited practical value (the JPO is redundant,
  59.   and alternative zero-checking methods that avoid using JCXZ are faster
  60.   on 386+ processors) but it does illustrate how to squeeze every
  61.   possible bit of information from the flag-states.
  62.  
  63.  
  64.   This code may be distributed as copyrighted "freeware", provided
  65.   it is not modified and the copyright notice remains intact.
  66.  
  67.   Please send your comments via E-mail to:
  68.  
  69.   Erik de Neve        Internet:  100121.1070@compuserve.com
  70.                     CompuServe:  100121,1070
  71.  
  72.  
  73.  
  74.  APPENDIX  -  Summary of INTEL 80XXX Conditional Jumps
  75.  ____________________________________________________________________
  76.  
  77.   Instruction                                  Will jump when...
  78.  ____________________________________________________________________
  79.  
  80.   JC     Jump if Carry                         CF=1
  81.   JB     Jump if Below                         CF=1
  82.   JNAE   Jump if Not Above or Equal            CF=1
  83.  
  84.   JNC    Jump if Not Carry                     CF=0
  85.   JNB    Jump if Not Below                     CF=0
  86.   JAE    Jump if Above or Equal                CF=0
  87.  ....................................................................
  88.  
  89.   JA     Jump if Above                         CF=0  and  ZF=0
  90.   JNBE   Jump if Not Below or Equal            CF=0  and  ZF=0
  91.  
  92.   JNA    Jump if Not Above                     CF=1  or  ZF=1
  93.   JBE    Jump if Below or Equal                CF=1  or  ZF=1
  94.  ....................................................................
  95.  
  96.   JCXZ   Jump if CX Zero                       CX=0
  97.  ....................................................................
  98.  
  99.   JO     Jump if Overflow (signed)             OF=1
  100.  
  101.   JNO    Jump if Not Overflow (signed)         OF=0
  102.  ....................................................................
  103.  
  104.   JP     Jump if Parity                        PF=1
  105.   JPE    Jump if Parity Even                   PF=1
  106.  
  107.   JNP    Jump if No Parity                     PF=0
  108.   JPO    Jump if Parity Odd                    PF=0
  109.  ....................................................................
  110.  
  111.   JGE    Jump if Greater or Equal (signed)     SF=OF
  112.   JNL    Jump if Not Less (signed)             SF=OF
  113.  
  114.   JNGE   Jump if Not Greater or Equal (signed) SF <> OF
  115.   JL     Jump if Less (signed)                 SF <> OF
  116.  ....................................................................
  117.  
  118.   JS     Jump if Signed (signed)               SF=1
  119.  
  120.   JNS    Jump if Not Signed (signed)           SF=0
  121.  ....................................................................
  122.  
  123.   JE     Jump if Equal                         ZF=1
  124.   JZ     Jump if Zero                          ZF=1
  125.  
  126.   JNE    Jump if Not Equal                     ZF=0
  127.   JNZ    Jump if Not Zero                      ZF=0
  128.  ....................................................................
  129.  
  130.   JG     Jump if Greater (signed)              ZF=0  and  SF=OF
  131.   JNLE   Jump if Not Less or Equal (signed)    ZF=0  and  SF=OF
  132.  
  133.   JNG    Jump if Not Greater (signed)          ZF=1  or  SF <> OF
  134.   JLE    Jump if Less or Equal (signed)        ZF=1  or  SF <> OF
  135.  ....................................................................
  136.  
  137.  
  138.